//
//  UIView+TiShiMessage.m
//  1gene
//
//  Created by 1jiyin on 16/4/13.
//  Copyright © 2016年 1jiyin. All rights reserved.
//

#import "UIView+TiShiMessage.h"
#define tishiTag101 100199
static NSInteger myTime101;
@implementation UIView (TiShiMessage)
-(void)showTiShiMessage:(NSString *)message
{
        UIView *view=[self viewWithTag:tishiTag101];
        if (view==nil) {
            view=[[UIView alloc]init];
            view.bounds=CGRectMake(0, 0, 165, 50);
            view.center=self.center;
            view.backgroundColor=[UIColor grayColor];
            view.tag=tishiTag101;
            view.layer.cornerRadius=3.0;
            view.layer.masksToBounds=YES;
            [self addSubview:view];
            
            UILabel *lab=[[UILabel alloc]initWithFrame:view.bounds];
            lab.text=message;
            lab.font=[UIFont systemFontOfSize:15];
            lab.textColor=[UIColor whiteColor];
            lab.textAlignment=NSTextAlignmentCenter;
            [view addSubview:lab];
            NSTimer *timer;
            timer=[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerRun) userInfo:nil repeats:NO];
        }
}
-(void)timerRun
{
    NSLog(@"定时器");
    if (myTime101>=1) {
        UIView *view=[self viewWithTag:tishiTag101];
        [view removeFromSuperview];
        myTime101=0;
        NSLog(@"定时器暂停了");
    }else{
        NSTimer *timer;
        timer=[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerRun) userInfo:nil repeats:NO];
    }
    myTime101++;
}
@end
